﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class InvoiceMap : EntityConfigurationBase<Invoice>
    {
        public InvoiceMap()
        {
            this.Property(p => p.Title).HasMaxLength(50).IsRequired();
            this.Property(p => p.Content).HasMaxLength(500).IsRequired();
            this.Property(p => p.Money).HasPrecision(18, 2);
            this.Property(p => p.AuditRemark).HasMaxLength(200).IsOptional();
            this.Property(p => p.ApplicantName).HasMaxLength(20).IsRequired();
            this.Property(p => p.AuditorName).HasMaxLength(20);
            this.Property(p => p.SpecialName).HasMaxLength(50).IsRequired();



            this.HasRequired(p => p.Special).WithMany().HasForeignKey(f => f.SpecialId);
            this.HasRequired(p => p.SellerSupplier).WithMany().HasForeignKey(f => f.SellerId);
            this.HasRequired(p => p.Applicant).WithMany().HasForeignKey(f => f.ApplicantId);
            this.HasOptional(p => p.Auditor).WithMany().HasForeignKey(f => f.AuditorId);
            this.HasOptional(p => p.Express).WithMany().HasForeignKey(f => f.ExpressId);
        }
    }
}
